//index.js
//获取应用实例
var app = getApp();

var util = require('../../utils/util.js');
var tcity = require("../../utils/citys.js");

Page({
    data: {
    },
    bindChange: function (e) {

    },
    closeErr: function () { //关闭错误
        util.clearError(this);
    },
    formSubmit: function (e) {
        var that = this;
        var passengerInfo = {
            "userId":app.globalData.userInfo.id,
            "userName":e.detail.value.userName,
            "idNumber":e.detail.value.idNumber
        }
        util.req("/wx/passenger/save", {"passengerInfo":passengerInfo} , function (data) {
            if (data.code == 1) {
                wx.showToast({
                    title: '操作成功',
                    icon: 'success',
                    duration: 2000
                })
            } else {
                util.isError(data.msg, that);
            }
        })
    },
    onLoad: function () {
        var that = this
        util.req("/wx/passenger/getInfo", {"wxUserId":app.globalData.userInfo.id}, function (data) {
            if(data.content != null){
                that.setData({
                    'passengerInfo': data.content,
                    "falg":false
                })
            }else{
                that.setData({
                    'passengerInfo': data.content,
                    "falg":true
                })
            }
        })
        console.log('初始化完成');
    }
})
